package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisManageRightRoleAdminRel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2018-11-26 15:05:53
 */
@Repository
public class AnalysisManageRightRoleAdminRelDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisManageRightRoleAdminRelDao.class);

    public AnalysisManageRightRoleAdminRel insert(final AnalysisManageRightRoleAdminRel analysisManageRightRoleAdminRel) {
        insert("AnalysisManageRightRoleAdminRel.insert", analysisManageRightRoleAdminRel);
        return analysisManageRightRoleAdminRel;
    }

    public Boolean updateInfoById(final AnalysisManageRightRoleAdminRel analysisManageRightRoleAdminRel) {
        return update("AnalysisManageRightRoleAdminRel.updateInfoById", analysisManageRightRoleAdminRel) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisManageRightRoleAdminRel.updateInfoByQuery", query) > 0;
    }

    public AnalysisManageRightRoleAdminRel selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("AnalysisManageRightRoleAdminRel.selectById", query);
    }

    public List<AnalysisManageRightRoleAdminRel> selectByQuery(final Query query) {
        return queryForList("AnalysisManageRightRoleAdminRel.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisManageRightRoleAdminRel.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        AnalysisManageRightRoleAdminRel analysisManageRightRoleAdminRel = new AnalysisManageRightRoleAdminRel();
        analysisManageRightRoleAdminRel.setDeleteFlag(1);
        analysisManageRightRoleAdminRel.setId(id);

        return update("AnalysisManageRightRoleAdminRel.updateInfoById", analysisManageRightRoleAdminRel) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisManageRightRoleAdminRel.deleteById", query) > 0;
    }

    public void insertForBatch(final List<AnalysisManageRightRoleAdminRel> list) {
        insert("AnalysisManageRightRoleAdminRel.insertForBatch", list);
    }
}